<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item label="外语水平" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="foreignLanguageLevel">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.foreignLanguageLevel" dictCode="foreign_language_level" placeholder="请选择外语水平" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="计算机能力" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerCapability">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.computerCapability" dictCode="computer_capability" placeholder="请选择计算机能力" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="有无驾照" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hasDrivingLicense">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.hasDrivingLicense" dictCode="YES_OR_NO" placeholder="请选择有无驾照" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="资格证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualification">
              <a-input :disabled="formDisabled" v-model="model.qualification" placeholder="请输入资格证书"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="职称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="professional">
              <a-input :disabled="formDisabled" v-model="model.professional" placeholder="请输入职称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="毕业院校" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="graduatedFrom">
              <a-input :disabled="formDisabled" v-model="model.graduatedFrom" placeholder="请输入毕业院校"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="专业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="major">
              <a-input :disabled="formDisabled" v-model="model.major" placeholder="请输入专业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="毕业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="graduationDate">
              <j-date :disabled="formDisabled" placeholder="请选择毕业时间" v-model="model.graduationDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="最高学历" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="highestDegree">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.highestDegree" dictCode="highest_degree" placeholder="请选择最高学历" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="教育方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="educationalMode">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.educationalMode" dictCode="educational_mode" placeholder="请选择教育方式" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ErpHrApplyQualificationsInfoForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
          foreignLanguageLevel: [{ required: true, message: '请选择外语水平', trigger: 'change' }],
          computerCapability: [{ required: true, message: '请选择计算机能力', trigger: 'change' }],
          hasDrivingLicense: [{ required: true, message: '请选择有无驾照', trigger: 'change' }],
          qualification: [{ required: true, message: '请输入资格证书', trigger: 'blur' }],
          graduatedFrom: [{ required: true, message: '请输入毕业院校', trigger: 'blur' }],
          // major: [{ required: true, message: '请输入专业', trigger: 'blur' }],
          // graduationDate: [{ required: true, message: '请选择毕业时间', trigger: 'change' }],
          highestDegree: [{ required: true, message: '请选择最高学历', trigger: 'change' }],
          educationalMode: [{ required: true, message: '请选择教育方式', trigger: 'change' }],
        },
        url: {
          add: "/api/erp/hr/apply/erpHrApplyQualificationsInfo/add",
          edit: "/api/erp/hr/apply/erpHrApplyQualificationsInfo/edit",
          queryById: "/api/erp/hr/apply/erpHrApplyQualificationsInfo/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            // that.confirmLoading = true;
            // let httpurl = '';
            // let method = '';
            // if(!this.model.id){
            //   httpurl+=this.url.add;
            //   method = 'post';
            // }else{
            //   httpurl+=this.url.edit;
            //    method = 'put';
            // }
            // httpAction(httpurl,this.model,method).then((res)=>{
            //   if(res.success){
            //     that.$message.success(res.message);
            //     that.$emit('ok');
            //   }else{
            //     that.$message.warning(res.message);
            //   }
            // }).finally(() => {
            //   that.confirmLoading = false;
            // })
            this.$emit('ok',this.model)
          }
        })
      },
    }
  }
</script>
